package com.songcha.module_home.ui.adapter

import android.content.Context
import android.graphics.Color
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.songcha.library_business.bean.book.BookBean
import com.songcha.library_business.bean.book.BookNetBean
import com.songcha.library_business.interfaces.IOnBookClickListener
import com.songcha.library_common.ui.view.CustomContainerLayout
import com.songcha.library_common.util.GlideUtil
import com.songcha.module_home.R

class HomeHomeEditorRecommendAdapter(list:MutableList<BookNetBean>,val listener:IOnBookClickListener):BaseQuickAdapter<BookNetBean,BaseViewHolder> (
    R.layout.home_home_item_editor_recommend,list){

    init {
        setOnItemClickListener{a,v,p->
            //TODO
            val iv=v.findViewById<ImageView>(R.id.home_home_item_iv_thumb)
            listener.onBookClick(list[p].bookId.toString(),iv)
        }
    }

    override fun convert(holder: BaseViewHolder, item: BookNetBean) {
       /* val fl = holder.getView<FrameLayout>(R.id.home_fl)
        if(holder.absoluteAdapterPosition%2==0){
            fl.setBackgroundColor(Color.RED)
        }else{
            fl.setBackgroundColor(Color.GREEN)
        }*/

        val iv=holder.getView<ImageView>(R.id.home_home_item_iv_thumb)
        GlideUtil.loadNetImage(iv,item.cover)
        val tv=holder.getView<TextView>(R.id.home_home_item_iv_title)
        tv.text=item.bookName
    }

}